package Ui;

import Ui.actions.processAction;
import java.awt.Color;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 *
 * @author dcpn13
 */
public class MainWindow extends JFrame {

    private String[] files;
    private String[] algorithmes;
    private String[] mesureDePerfo;
    
    JComboBox graphComboBox;
    JComboBox algoComboBox;
    JComboBox mesureComboBox;
    JComboBox orientedGraphComboBox;

    public MainWindow() {
        super();
        
        this.files = new String[]{"grid5-5.txt", "grid6-6.txt", "grid9-9.txt", "grid10-10.txt", "grid20-20.txt", "grid30-30.txt", "grid40-40.txt", "grid50-50.txt"};
        this.algorithmes = new String[]{"DijkstraTableau","DijkstraTas","DijkstraListe","MooreTableau","MooreTas","MooreListe"};
        this.mesureDePerfo = new String[]{"oui","non"};
        
        this.algoComboBox = new JComboBox(this.algorithmes);
        this.graphComboBox = new JComboBox(this.files);
        this.mesureComboBox = new JComboBox(this.mesureDePerfo);
        this.orientedGraphComboBox = new JComboBox(new String[]{"orienté","non orienté"});
        
        build();
    }

    private void build() {
        setTitle("Algo DRAMSY Christian"); //On donne un titre à l'application
        setSize(300, 200); //On donne une taille à notre fenêtre
        setLocationRelativeTo(null); //On centre la fenêtre sur l'écran
        setResizable(false); //On interdit la redimensionnement de la fenêtre
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //On dit à l'application de se fermer lors du clic sur la croix
        setContentPane(this.buildContent());
    }

    private JPanel buildContent() {
        JPanel panel = new JPanel();
        panel.setLayout(new GridLayout(0, 2));
        panel.setBackground(Color.white);
        panel.add(new JLabel("Selection de graphe"));
        panel.add(this.graphComboBox);
        
        panel.add(new JLabel("Orientation du graphe"));
        panel.add(this.orientedGraphComboBox);
        
        panel.add(new JLabel("Selection de l'algorithme"));
        panel.add(this.algoComboBox);
        
        panel.add(new JLabel("Calcul de temps ?"));
        panel.add(this.mesureComboBox);
        
        panel.add(new JLabel(""));
        panel.add(new JButton(new processAction(this, "Executer")));
        return panel;
    }

    public JComboBox getAlgoComboBox() {
        return algoComboBox;
    }

    public JComboBox getGraphComboBox() {
        return graphComboBox;
    }

    public JComboBox getMesureComboBox() {
        return mesureComboBox;
    }

    public JComboBox getOrientedGraphComboBox() {
        return orientedGraphComboBox;
    }
    
    
}
